package edu.washington.tcss360.burningpenguins.client;

import java.util.Arrays;
import java.util.LinkedList;

import edu.washington.tcss360.burningpenguins.data.DataObject;
import edu.washington.tcss360.burningpenguins.data.Review;
import edu.washington.tcss360.burningpenguins.database.BPDatabaseConnection;
import edu.washington.tcss360.burningpenguins.queries.QueryBy;
import edu.washington.tcss360.burningpenguins.util.DataObjectField;
import edu.washington.tcss360.burningpenguins.util.DataObjectFieldDataType;

/**
 * A class for performing operations on the Review table.
 * 
 * @author Chris Gelatt
 * @version 1.0
 * @since 2013-11-13
 *
 */
public class ReviewClient extends DataObjectClient
{
	public ReviewClient(BPDatabaseConnection connection)
	{
		super(connection);
		tableName = "Review";
		classPath = "edu.washington.tcss360.burningpenguins.data.Review";
		validQueries = new LinkedList<>();
		objectFields = new LinkedList<>();
		
		//TODO - Populate valid queries
		
		objectFields.add(new DataObjectField("UserId", "UserId", DataObjectFieldDataType.INTEGER, true));
		objectFields.add(new DataObjectField("PaperId", "PaperId", DataObjectFieldDataType.INTEGER, true));
		objectFields.add(new DataObjectField("Question1", "Question1", DataObjectFieldDataType.STRING, true));
		objectFields.add(new DataObjectField("Rating1", "Rating1", DataObjectFieldDataType.INTEGER, true));
		objectFields.add(new DataObjectField("Question2", "Question2", DataObjectFieldDataType.STRING, true));
		objectFields.add(new DataObjectField("Rating2", "Rating2", DataObjectFieldDataType.INTEGER, true));
		objectFields.add(new DataObjectField("Question3", "Question3", DataObjectFieldDataType.STRING, true));
		objectFields.add(new DataObjectField("Rating3", "Rating3", DataObjectFieldDataType.INTEGER, true));
		objectFields.add(new DataObjectField("Question4", "Question4", DataObjectFieldDataType.STRING, true));
		objectFields.add(new DataObjectField("Rating4", "Rating4", DataObjectFieldDataType.INTEGER, true));
		objectFields.add(new DataObjectField("Question5", "Question5", DataObjectFieldDataType.STRING, true));
		objectFields.add(new DataObjectField("Rating5", "Rating5", DataObjectFieldDataType.INTEGER, true));
		objectFields.add(new DataObjectField("Question6", "Question6", DataObjectFieldDataType.STRING, true));
		objectFields.add(new DataObjectField("Rating6", "Rating6", DataObjectFieldDataType.INTEGER, true));
		objectFields.add(new DataObjectField("Question7", "Question7", DataObjectFieldDataType.STRING, true));
		objectFields.add(new DataObjectField("Rating7", "Rating7", DataObjectFieldDataType.INTEGER, true));
		objectFields.add(new DataObjectField("Question8", "Question8", DataObjectFieldDataType.STRING, true));
		objectFields.add(new DataObjectField("Rating8", "Rating8", DataObjectFieldDataType.INTEGER, true));
		objectFields.add(new DataObjectField("Question9", "Question9", DataObjectFieldDataType.STRING, true));
		objectFields.add(new DataObjectField("Rating9", "Rating9", DataObjectFieldDataType.INTEGER, true));
		objectFields.add(new DataObjectField("SummaryRating", "SummaryRating", DataObjectFieldDataType.INTEGER, true));
		objectFields.add(new DataObjectField("SummaryComments", "SummaryComments", DataObjectFieldDataType.STRING, true));
	}
	
	/**
	 * {@inheritDoc}
	 */
	public Review get(Integer id)
	{
		return (Review)getBase(id);
	}
	
	/**
	 * {@inheritDoc}
	 */
	public Review[] getAll(QueryBy[] dbQueries)
	{
		DataObject[] baseArray = getAllBase(dbQueries);
		return Arrays.copyOf(baseArray, baseArray.length, Review[].class);
	}
}
